<?php include('./templete/public/head.php')?>
<script src="_js/plug/jquery.raty.min.js"></script>
<body class="bgcolor mbHeight">
<!--金点子详情-->
<div class="golden-idea-detail zj-detail-main">
    <div class="ideal-detail1">
        <div class="detail-text">
            <p class="p1 pfbold"><?php echo $rows['title']?></p>
            <div class="p2">
                <?php echo $rows['problem_content']?>
            </div>
            <p class="p3">
                <img src="<?php echo $rows['user_head']?>" class="head-img"/>
                <span><?php echo $rows['user_name']?><?php echo date('Y-m-d' ,strtotime($rows['add_time']))?></span>
            </p>
        </div>
    </div>
    <?php if((($rows['status']==13)||($rows['status']==14))&&(!$is_score)&&($is_acceptor)){?>
    <div class="ideal-detail2">
        <div class="comm-btn comm-btn2 assess-btn">
            <span class="color1 adopt">评分</span>
        </div>
    </div>
    <?php }?>
        <div class="ideal-detail2">
                <div class="c-top">
                    <ul class="comm-table-view">
                        <li class="table-view-cell">
                            <a style="align-items: center">
                                <span>得分</span>
                                <div class="top-text text1" id="star2">
<!--                                    <span>--><?php //echo $final_score?><!--</span>-->
                                </div>
                                <span><?php echo $final_score?></span>
                            </a>
                        </li>
                    </ul>
                </div>
                <hr class="bgcolor" />
        </div>
    <div class="comment-main">
        <ul class="comment-list">

        </ul>
    </div>

    <!--底部评论固定-->
    <div class="comment-fixed">

        <p class="p2"><input type="text" id="comment" placeholder="点评一下吧"/></p>
        <p class="p3"><a id="publis_comment">提交</a></p>
    </div>

</div>
</body>
<script>

    $('#star').raty({ number: 10, path: '_images' ,width:'100%'});
    $('#star2').raty({ number: 10, path: '_images' ,width:'72%',readOnly:true,score:<?php echo $final_score?>});

    $('.adopt').click(function () {
            location.href = '/index/jdz/acceptor/id/' + '<?php echo $rows['id']?>'
    });

    $('#publis_comment').click(function () {
        var comment_content = $("#comment").val();
        if(!comment_content){
            layer.msg('请输入评论内容');
            return false;
        }
        $.ajax({
            url:'<?php echo url('publish_comment')?>',
            data:{
                id:<?php echo $rows['id']?>,
                comment:comment_content,
            },
            type:'post',
            success:function (data) {
                if(data.code==1){
                    layer.msg(data.msg);
                    setTimeout(function () {
                        location.reload();
                    },1000)
                }else{
                    layer.msg(data.msg);
                }
            }
        })
    })


    //获取评论
    function get_comment() {
        $.ajax({
            url:'<?php echo url('jdz/get_comment_list')?>',
            data:{
                jdz_id:<?php echo $rows['id']?>,
            },
            success:function (data) {
                $('.comment-list').append(data);
            }
        })
    };
    get_comment();

    //获取更多评论
    $(function() {
        var page = 2;
        var load_flag = true;
        $(window).scroll(function() {
            var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            var documentheight = parseFloat($(document).height());
            if (documentheight - totalheight <= 200) {
                $("#loadmore").show();
                if(load_flag){
                    load_flag=!load_flag;
                    $.ajax({
                        url: '<?php echo url('jdz/get_comment_list')?>',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            page:page,
                            jdz_id:<?php echo $rows['id']?>,
                        },
                        success: function(data) {
                            if (data) {
                                $('.comment-list').append(data);
                                load_flag=!load_flag;
                                page++;
                            }
                        }
                    })
                }
            }
        });
    });
</script>

</html>